package org.LZQ.ShortLink.admin.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.LZQ.ShortLink.admin.domain.User;
import org.LZQ.ShortLink.admin.dto.req.UserLoginReqDTO;
import org.LZQ.ShortLink.admin.dto.req.UserRegisterReqDTO;
import org.LZQ.ShortLink.admin.dto.req.UserUpdateReqDTO;
import org.LZQ.ShortLink.admin.dto.resp.UserLoginRespDTO;
import org.LZQ.ShortLink.admin.dto.resp.UserRespDTO;
import org.springframework.transaction.annotation.Transactional;

/**
* @description 针对表【user】的数据库操作Service
* @createDate 2024-08-18 23:13:56
*/
public interface UserService extends IService<User> {
    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    UserRespDTO getUserByUsername(String username);

    /**
     * 判断用户名是否存在
     * @param username
     * @return
     */
    Boolean hasUsername(String username);

    /**
     * 注册用户
     * @param requestParam
     */
    @Transactional(rollbackFor = Exception.class)
    void registerUser(UserRegisterReqDTO requestParam);

    /**
     * 用户登录
     * @param requestParam
     * @return
     */
    UserLoginRespDTO loginUser(UserLoginReqDTO requestParam);

    /**
     * 更新用户信息
     * @param requestParam
     */
    void updateUser(UserUpdateReqDTO requestParam);

    /**
     * 检查用户是否登录
     * @param username
     * @param token
     * @return
     */
    boolean checkLogin(String username,String token);

    /**
     * 退出登录
     * @param username
     * @param token
     */
    void logout(String username, String token);
}
